﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace X3DLib
{
    public class BackgroundCreater
    {
        private string scene;
        private string attrs;
        private Background background;

        /// <summary>
        /// 背景的构造函数
        /// </summary>
        /// <param name="scene">场景，day|night|diy</param>
        public BackgroundCreater(string scene)
        {
            this.scene = scene;
            background = new Background();
        }

        /// <summary>
        /// 背景的构造函数
        /// </summary>
        /// <param name="scene">场景，day|night|diy</param>
        /// <param name="attrs"></param>
        public BackgroundCreater(string scene, string attrs)
        {
            this.attrs = attrs;
            this.scene = scene;
            background = new Background();
        }

        /// <summary>
        /// 返回一个背景
        /// </summary>
        /// <returns></returns>
        public Background GetBackground()
        {
            if (scene.Equals("day"))
            {
                return DayBackground();
            }
            else if (scene.Equals("night"))
            {
                return NightBackground();
            }
            else if (scene.Equals("diy"))
            {
                return DIYBackground();
            }
            else
            {
                return background;
            }
        }

        private Background DayBackground()
        {
            //background.skyAngle = "1.309 1.571";
            //background.skyColor = "0 0.2 0.7 0 0.5 1 1 1 1";//"0.24 0.84 1";
            //background.groundColor = "0.5 0.4 0.3";
            background.setAttrs("skyAngle|1.309 1.571,skyColor|0 0.2 0.7 0 0.5 1 1 1 1,groundColor|0.5 0.4 0.3");
            return background;
        }

        private Background NightBackground()
        {
            //background.skyAngle = "1.309 1.571";
            //background.skyColor = "0 0.2 0.7 0 0 0 0.5 0.5 0.5";
            //background.groundColor = "0.2 0.2 0.2";
            background.setAttrs("skyAngle|1.309 1.571,skyColor|0 0.2 0.7 0 0 0 0.5 0.5 0.5,groundColor|0.2 0.2 0.2");
            return background;
        }

        private Background DIYBackground()
        {
            background.setAttrs(attrs);
            return background;
        }
        
    }
}
